package com.yixun.qfbao.hander;

import com.yixun.qfbao.api.service.PersonnelService;
import com.yixun.qfbao.apidto.GetPartnerByAgentOrgReqDto;
import com.yixun.qfbao.apidto.GetPartnerByAgentOrgResDto;
import com.yixun.qfbao.dto.base.BaseRequestDTO;
import com.yixun.qfbao.dto.base.BaseResponseDTO;
import com.yixun.qfbao.hander.base.CommonAbstractHander;
import com.yixun.qfbao.vo.GetPartnerByAgentOrgReqVo;
import com.yixun.qfbao.xf.model.enums.ResultEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description
 * @Date 2017/11/24
 * @Author sangtao
 * @Computer Administrator
 */
@Service("getPartnerByAgentOrgHander")
public class GetPartnerByAgentOrgHander extends CommonAbstractHander {
    private static Logger logger= LoggerFactory.getLogger(GetPartnerByAgentOrgHander.class);
    @Autowired
    PersonnelService personnelService;
    @Override
    public BaseResponseDTO doBusiness(BaseRequestDTO reqDto) {
        GetPartnerByAgentOrgReqVo req = (GetPartnerByAgentOrgReqVo)reqDto;
        GetPartnerByAgentOrgReqDto getPartnerByAgentOrgReqDto = req.getParams();
        BaseResponseDTO<GetPartnerByAgentOrgResDto> res = new BaseResponseDTO<GetPartnerByAgentOrgResDto>();
        GetPartnerByAgentOrgResDto resDto = new GetPartnerByAgentOrgResDto();
        try{
            resDto = personnelService.getPartnerByAgentOrg(getPartnerByAgentOrgReqDto);
        } catch (Exception e) {
            logger.error("GetPartnerByAgentOrgHander error: {}", e);
            resDto.setResult(ResultEnum.FAIL.getNo());
            resDto.setResultMsg("获取经纪人失败!");
        }
        res.setResData(resDto);
        res.setResult(resDto.getResult());
        return res;
    }
}
